package com.longdaji.decoration.data.network;

import com.longdaji.decoration.bean.Account;
import com.longdaji.decoration.bean.Balance;
import com.longdaji.decoration.bean.Collection;
import com.longdaji.decoration.bean.CommonResult;
import com.longdaji.decoration.bean.Feedback;
import com.longdaji.decoration.bean.GoodsComment;
import com.longdaji.decoration.bean.MyCities;
import com.longdaji.decoration.bean.MyLogistics;
import com.longdaji.decoration.bean.MyProvinces;
import com.longdaji.decoration.bean.MyUniversities;
import com.longdaji.decoration.bean.OperationResult;
import com.longdaji.decoration.bean.Order;
import com.longdaji.decoration.bean.Orders;
import com.longdaji.decoration.bean.ReceivingAddress;
import com.longdaji.decoration.bean.RefundGoods;
import com.longdaji.decoration.data.bean.AdBean;
import com.longdaji.decoration.data.bean.AddressBean;
import com.longdaji.decoration.data.bean.AssessUrlBean;
import com.longdaji.decoration.data.bean.AvailableMoneyBean;
import com.longdaji.decoration.data.bean.AvailableScoreBean;
import com.longdaji.decoration.data.bean.CaptainCheckBean;
import com.longdaji.decoration.data.bean.CaptainInfoBean;
import com.longdaji.decoration.data.bean.CartBean;
import com.longdaji.decoration.data.bean.GoodsAccountBean;
import com.longdaji.decoration.data.bean.GoodsBean;
import com.longdaji.decoration.data.bean.GoodsCategory;
import com.longdaji.decoration.data.bean.GoodsChosensBean;
import com.longdaji.decoration.data.bean.GoodsCommentBean;
import com.longdaji.decoration.data.bean.GoodsCommentListBean;
import com.longdaji.decoration.data.bean.GoodsDetailImageBean;
import com.longdaji.decoration.data.bean.GoodsImagesBean;
import com.longdaji.decoration.data.bean.GoodsMotifsBean;
import com.longdaji.decoration.data.bean.GoodsSkuBean;
import com.longdaji.decoration.data.bean.InviteCodeBean;
import com.longdaji.decoration.data.bean.LogisticsBean;
import com.longdaji.decoration.data.bean.OrderBean;
import com.longdaji.decoration.data.bean.PakageBean;
import com.longdaji.decoration.data.bean.PayBean;
import com.longdaji.decoration.data.bean.ShareUrlBean;
import com.longdaji.decoration.data.bean.SignInBean;
import com.longdaji.decoration.data.bean.SignInDataBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Flowable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;

/**
 * Created by longtao on 2018/1/4.
 */

public interface ApiService {
    @POST("goods/200002")
    Flowable<HttpResponse<GoodsCategory>> getGoodsCatergory();

    @FormUrlEncoded
    @POST("goods/200003")
    Flowable<HttpResponse<GoodsBean>> getGoodsList(@Field("cateId") String cateId, @Field("orderBy") String orderBy, @Field("usertId") String userId);

    @FormUrlEncoded
    @POST("goodsImg/220001")
    Flowable<HttpResponse<GoodsImagesBean>> getGoodsImages(@Field("goodsId") String goodId);

    @FormUrlEncoded
    @POST("goodsDetailImg/230001")
    Flowable<HttpResponse<GoodsDetailImageBean>> getGoodsDetailImage(@Field("goodsId") String goodId);

    @POST("goodsMotif/240001")
    Flowable<HttpResponse<GoodsMotifsBean>> getTopicImage();

    @POST("goodsChosen/250001")
    Flowable<HttpResponse<GoodsChosensBean>> getChosenImage();

    @Headers({"Content-type:application/json;charset=UTF-8"})
    @POST("account/100017")
    Flowable<HttpResponse<OrderBean>> creatOrder(@Body RequestBody requestBody);

    @GET("auth/h5")
    Flowable<AssessUrlBean> getAssessTypeUrl(@Query("userId") String userId, @Query("authType") int authType);

    @POST("account/100031")
    Flowable<HttpResponse<List<PakageBean>>> getPakagePattern();

    @POST("account/100032")
    Flowable<HttpResponse<List<LogisticsBean>>> getLogisticsPattern();


    @GET("account/100035")
    Flowable<HttpResponse<AvailableScoreBean>> getAvailableScore(@Query("userId") String userId);

    @GET("account/100036")
    Flowable<HttpResponse<AvailableMoneyBean>> getAvailableMoney(@Query("userId") String userId);

    @FormUrlEncoded
    @POST("goods/200004")
    Flowable<HttpResponse<GoodsSkuBean>> getGoodsDetail(@Field("goodsId") String goodId, @Field("userId") String userId);

    @FormUrlEncoded
    @POST("cart/400000")
    Flowable<HttpResponse<CartBean>> getCartList(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("pay/600004")
    Flowable<HttpResponse> verifyCreditScore(@Field("certNo") String certNo, @Field("name") String name);

    @FormUrlEncoded
    @POST("captain/110001")
    Flowable<HttpResponse> applyCaptain(@Field("userid") String userId, @Field("captainName") String captainName, @Field("dormitoryId") String dormitoryId, @Field("telephone") String telephone);

    @FormUrlEncoded
    @POST("cart/400002")
    Flowable<HttpResponse> deleteFromChart(@Field("userId") String userId, @Field("cartGoodsRecordId") String[] cartGoodsRecordId);

    @FormUrlEncoded
    @POST("cart/400004")
    Flowable<HttpResponse<GoodsAccountBean>> accountFromChart(@Field("userId") String userId, @Field("cartGoodsRecordId") List<String> idList);

    @FormUrlEncoded
    @POST("goodsCollection/300005")
    Flowable<HttpResponse> disCollectGoodsList(@Field("userId") String userId, @Field("idList") List<String> idList);

    @FormUrlEncoded
    @POST("goodsCollection/300007")
    Flowable<HttpResponse> collectGoodsList(@Field("userId") String userId, @Field("idList") List<String> idList);

    @FormUrlEncoded
    @POST("captain/110006")
    Flowable<HttpResponse> getCaptainInfo(@Field("dormitoryId") String dormitoryId, @Field("dormitoryName") String dormitoryName);

    @FormUrlEncoded
    @POST("cart/400003")
    Flowable<HttpResponse> modifyCartItemNum(@FieldMap Map<String, String> options);

    @FormUrlEncoded
    @POST("cart/400001")
    Flowable<HttpResponse> addGoodsSkuToCart(@FieldMap Map<String, Object> options);

    @FormUrlEncoded
    @POST("goodsComment/210001")
    Flowable<HttpResponse<GoodsCommentListBean>> getGoodsComments(@Field("goodsId") String goodsId, @Field("userId") String userId);

    @FormUrlEncoded
    @POST("goodsComment/210004")
    Flowable<HttpResponse<GoodsCommentBean>> getDefaultComment(@Field("goodsId") String goodsId);

    @FormUrlEncoded
    @POST("goodsComment/210003")
    Flowable<HttpResponse> likeGoodsOrNot(@Field("userId") String userId, @Field("commentsId") String commentsId, @Field("isLike") String isLike);

    @FormUrlEncoded
    @POST("keepSign/120000")
    Flowable<HttpResponse<SignInDataBean>> getSignInData(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("keepSign/120001")
    Flowable<HttpResponse<SignInBean>> signIn(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("account/100015")
    Flowable<HttpResponse<AddressBean.Address>> getDefaultAddress(@Field("userid") String userid);

    @FormUrlEncoded
    @POST("captain/110007")
    Flowable<HttpResponse<CaptainCheckBean>> getCaptainApplyStatus(@Field("userId") String userId);

    @FormUrlEncoded
    @POST("account/100012")
    Flowable<HttpResponse<AddressBean>> getAddressList(@Field("userid") String userid);

    @FormUrlEncoded
    @POST("pay/600001")
    Flowable<HttpResponse<PayBean>> getPayOrderInfo(@FieldMap Map<String, Object> options);

    //account
    @GET("account/100001")
    Flowable<HttpResponse> doRegisterApi(@Query("username") String username,
                                         @Query("name") String name,
                                         @Query("telephone") String telephone,
                                         @Query("password") String password,
                                         @Query("remark") String remark,
                                         @Query("sign") String sign,
                                         @Query("constellation") String constellation,
                                         @Query("genger") String genger,
                                         @Query("head_img_location") String headImgLocation,
                                         @Query("registerTime") String registerTime,
                                         @Query("campusName") String campusName,
                                         @Query("dormitoryName") String dormitoryName,
                                         @Query("isGraduate") int isGraduate);

    @POST("account/100002")
    Flowable<HttpResponse> doUsernameVerifyApi(@Query("username") String username,
                                               @Query("telephone") String telephone);

    @POST("account/100003")
    Flowable<HttpResponse> doTelephoneVerifyApi(@Query("username") String username,
                                                @Query("telephone") String telephone);

    @POST("account/100004")
    Flowable<HttpResponse<Account>> doPasswordLoginApi(@Query("username") String account,
                                                       @Query("password") String password,
                                                       @Query("loginTime") String loginTime);

    @POST("account/100024")
    Flowable<HttpResponse> doVerificationRequest(@Query("telephone") String telephone,
                                                 @Query("code") String code);

    @POST("account/100025")
    Flowable<HttpResponse> doVerificationResult(@Query("telephone") String telephone,
                                                @Query("code") String code);

    @POST("account/100027")
    Flowable<HttpResponse> doForgetPasswordApi(@Query("telephone") String telephone,
                                               @Query("password") String password);

    @POST("account/100005")
    Flowable<HttpResponse> doUpdatePersonalInfoApi(@Query("userid") String userid,
                                                   @Query("username") String username,
                                                   @Query("name") String name,
                                                   @Query("remark") String remark,
                                                   @Query("sign") String sign,
                                                   @Query("constellation") String constellation,
                                                   @Query("genger") String gender,
                                                   @Query("head_img_location") String head_img_location,
                                                   @Query("credits") int credits);

    @POST("account/100006")
    Flowable<HttpResponse> doUpdateAccountApi(@Query("userid") String userid,
                                              @Query("username") String username,
                                              @Query("telephone") String telephone,
                                              @Query("password") String password);

    @POST("account/100007")
    Flowable<HttpResponse> doUpdateCampusApi(@Query("userid") String userid,
                                             @Query("campusName") String campusName,
                                             @Query("dormitoryName") String dormitoryName);

    @POST("account/100008")
    Flowable<HttpResponse<Account>> doGetUserInfoApi(@Query("userid") String userid,
                                                     @Query("userName") String userName);

    @POST("account/100011")
    Flowable<HttpResponse> doAddReceivingAddressApi(@Query("userid") String userid,
                                                    @Query("contactPerson") String contactPerson,
                                                    @Query("contactTelephone") String contactTelephone,
                                                    @Query("province") String province,
                                                    @Query("city") String city,
                                                    @Query("district") String district,
                                                    @Query("street") String street,
                                                    @Query("detailAddress") String detailAddress,
                                                    @Query("createTime") String createTime,
                                                    @Query("defaultAddress") String defaultAddress,
                                                    @Query("zipcode") String zipcode,
                                                    @Query("delFlag") String delFlag);

    @POST("account/100012")
    Flowable<HttpResponse<ReceivingAddress>> doGetReceivingAddressApi(@Query("userid") String userid,
                                                                      @Query("userName") String userName);

    @POST("account/100013")
    Flowable<HttpResponse> doDeleteReceivingAddressApi(@Query("userid") String userid,
                                                       @Query("shippingId") int shippingId);

    @FormUrlEncoded
    @POST("account/100014")
    Flowable<HttpResponse> setDefaultAddr(@Field("userid") String userid, @Field("defaultAddress") String defaultAddress, @Field("shippingId") long shippingId);

    @POST("account/100014")
    Flowable<HttpResponse> doUpdateReceivingAddressApi(@Query("userid") String userid,
                                                       @Query("contactPerson") String contactPerson,
                                                       @Query("contactTelephone") String contactTelephone,
                                                       @Query("province") String province,
                                                       @Query("city") String city,
                                                       @Query("district") String district,
                                                       @Query("street") String street,
                                                       @Query("detailAddress") String detailAddress,
                                                       @Query("createTime") String createTime,
                                                       @Query("defaultAddress") String defaultAddress,
                                                       @Query("shippingId") int shippingId,
                                                       @Query("zipcode") String zipcode,
                                                       @Query("delFlag") String delFlag);

    @POST("account/100015")
    Flowable<HttpResponse<ReceivingAddress>> doGetDefaultReceivingAddressApi(@Query("userid") String userid,
                                                                             @Query("userName") String userName);

    @GET("account/100016")
    Flowable<HttpResponse<Orders>> doGetOrderApi(@Query("userid") String userid,
                                                 @Query("status") String status,
                                                 @Query("orderNo") String orderNo);

    //100017 订单生成接口
    // TODO: 2018/3/19 0019 100017
    @POST("account/100017")
    Flowable<HttpResponse> doGenerateOrderApi(@Body Order order);


    //100018 返回值似乎不对
    // TODO: 2018/3/19 0019 100018
    @POST("account/100018")
    Flowable<HttpResponse<MyLogistics>> doSeeLogisticsApi(@Query("orderCode") String orderNo);

    @POST("account/100019")
    Flowable<HttpResponse<OperationResult>> doCancelOrderApi(@Query("userid") String userid,
                                                             @Query("orderNo") String orderNo);

    @POST("account/100020")
    Flowable<HttpResponse<CommonResult>> doRefundApi(@Query("userid") String userid,
                                                     @Query("userName") String userName);

    @POST("account/100021")
    Flowable<HttpResponse<CommonResult>> doExchangeApi(@Query("userid") String userid,
                                                       @Query("userName") String userName);

    @POST("account/100026")
    Flowable<HttpResponse> doGetUpTokenApi();

    @POST("account/100028")
    Flowable<HttpResponse> doReturnGoodsApi(@Query("userid") String userid, @Query("orderNum") String orderNum, @Query("skuId") int skuId,
                                            @Query("skuNum") int skuNum, @Query("captainId") long captainId,
                                            @Query("refundMoney") double refundMoney, @Query("refundReason") String refundReason,
                                            @Query("refundDesc") String refundDesc, @Query("delFlag") String delFlag);

    @POST("account/100030")
    Flowable<HttpResponse> doReceivingGoodsApi(@Query("userid") String userid, @Query("orderNo") String orderNo);

    @GET("account/100033")
    Flowable<HttpResponse<Balance>> doGetBalanceDetailApi(@Query("userId") String userId,
                                                          @Query("type") int type,
                                                          @Query("pageNo") int pageNo,
                                                          @Query("pageSize") int pageSize);


    //dictionary
    @POST("dictionary/500000")
    Flowable<HttpResponse<MyProvinces>> doGetProvince();

    @POST("dictionary/500003")
    Flowable<HttpResponse<MyCities>> doGetCity();

    @POST("dictionary/500004")
    Flowable<HttpResponse<MyUniversities>> doGetCampus();

    //collection
    @POST("goodsCollection/300001")
    Flowable<HttpResponse<Collection>> doGetCollectionApi(@Query("userid") String userid);

    @POST("goodsCollection/300005")
    Flowable<HttpResponse> doDeleteCollectionApi(@Query("idList") String idList, @Query("userId") String userId);

    //comment
    @POST("goodsComment/210002")
    Flowable<HttpResponse> doGoodsCommentApi(@Body GoodsComment goodsComment);


    //refund
//    @POST("account/100029")
//    Flowable<HttpResponse<OrderRefund>> doGetRefundOrderApi(@Query("userid") String userid);

    @POST("account/100029")
    Flowable<HttpResponse<List<RefundGoods>>> doGetRefundGoodsApi(@Query("userid") String userid);


    //feedback
    @POST("userView/110001")
    Flowable<HttpResponse> doFeedbackApi(@Query("userId") String userId,
                                         @Query("connection") String connection,
                                         @Query("viewContent") String viewContent);

    @POST("userView/110002")
    Flowable<HttpResponse<Feedback>> doGetFeedbackApi(@Query("userId") String userId);

    @POST("account/100040")
    Flowable<HttpResponse<ShareUrlBean>> getShareUrl();

    @POST("account/100037")
    Flowable<HttpResponse<InviteCodeBean>> verifyInviteCode(@Query("inviteCode") String inviteCode);

    @POST("visit/260001")
    Flowable<HttpResponse> countVisitNum(@Query("goodsId") String goodsId, @Query("cateId") String cateId, @Query("userId") String userId, @Query("visitTime") String visitTime);

    @POST("captain/110008")
    Flowable<HttpResponse<List<CaptainInfoBean>>> queryCaptainInfo(@Query("userId") String userId);

    @GET("goodsChosen/250002")
    Flowable<HttpResponse<AdBean>> getAd();
}
